<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
      <el-card>
        <el-form-item label="数据集名称" prop="name">
          <el-input
            v-model="queryParams.name"
            placeholder="请输入数据集名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-card>
    </el-form>

    <el-card style="margin-top:10px;">
      <el-table v-loading="loading" :data="datasetList" border>
        <el-table-column label="名称" align="center" prop="name" />
        <el-table-column label="编码" align="center" prop="code" />
        <el-table-column label="类型" align="center" prop="type" width="120">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sy_dataset_type" :value="scope.row.type"/>
          </template>
        </el-table-column>
        <el-table-column label="状态" align="center" prop="status" width="120">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sy_dataset_status" v-if="scope.row.status==0" style="color:blue" :value="scope.row.status"/>
            <dict-tag :options="dict.type.sy_dataset_status" v-if="scope.row.status==1" style="color:green" :value="scope.row.status"/>
            <dict-tag :options="dict.type.sy_dataset_status" v-if="scope.row.status==2" style="color:red" :value="scope.row.status"/>
          </template>
        </el-table-column>
        <el-table-column label="创建人" align="center" prop="creator" width="120" />
        <el-table-column label="创建日期" align="center" prop="createTime" width="120">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="发布人员" align="center" prop="publisher" width="120" />
        <el-table-column label="发布日期" align="center" prop="publishTime" width="120">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.publishTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="160">
          <template slot-scope="scope">
            <el-dropdown :hide-on-click="false">
              <span class="el-dropdown-link" style="color:blue;">
                更多操作<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="handleView(scope.row)"><i class="el-icon-document"></i>详情</el-dropdown-item>
                <el-dropdown-item style="color:blue;" @click.native="handleDataAuth(scope.row)"><i class="el-icon-sold-out"></i>数据权限</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
      
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>

    <el-dialog :title="vTitle" :visible.sync="vOpen" width="70%" append-to-body>
      <el-card style="margin-top:-30px">
        <div slot="header" class="clearfix">
          <span style="font-weight:bold;font-size:18px;color:#329dff;">数据集信息</span>
        </div>
        <el-descriptions :column="2" border>
          <el-descriptions-item label="名称" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ datasetInfo.name }}
          </el-descriptions-item>
          <el-descriptions-item label="代码" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ datasetInfo.code }}
          </el-descriptions-item>
          <el-descriptions-item label="类型" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            <dict-tag :options="dict.type.sy_dataset_type" :value="datasetInfo.type"/>
          </el-descriptions-item>
          <el-descriptions-item label="状态" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            <dict-tag :options="dict.type.sy_dataset_status" :value="datasetInfo.status"/>
          </el-descriptions-item>
          <el-descriptions-item label="创建人员" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ datasetInfo.creator }}
          </el-descriptions-item>
          <el-descriptions-item label="创建日期" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ parseTime(datasetInfo.createTime, '{y}-{m}-{d}') }}
          </el-descriptions-item>
          <el-descriptions-item label="发布人员" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ datasetInfo.publisher }}
          </el-descriptions-item>
          <el-descriptions-item label="发布日期" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ parseTime(datasetInfo.publishTime, '{y}-{m}-{d}') }}
          </el-descriptions-item>
          <el-descriptions-item label="下架人员" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ datasetInfo.updator }}
          </el-descriptions-item>
          <el-descriptions-item label="下架日期" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'40%',color: '#329dff' }">
            {{ parseTime(datasetInfo.updateTime, '{y}-{m}-{d}') }}
          </el-descriptions-item>
        </el-descriptions>
        <el-descriptions :column="1" border style="margin-top:-2px;">
          <el-descriptions-item label="描述" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'90%',color: '#329dff' }">
            {{ datasetInfo.describe }}
          </el-descriptions-item>
          <el-descriptions-item label="备注" :labelStyle="{width:'10%','text-align': 'center'}" :contentStyle="{ width:'90%',color: '#329dff' }">
            {{ datasetInfo.remark }}
          </el-descriptions-item>
        </el-descriptions>
      </el-card>

      <el-card style="margin-top:10px;">
        <div slot="header" class="clearfix">
          <span style="font-weight:bold;font-size:18px;color:#329dff;">数据对象</span>
        </div>
        <el-table v-if="objectsList.length>0" :data="objectsList" border style="margin-top:10px;">
          <el-table-column label="序号" align="center" type="index" width="55" />
          <el-table-column label="对象名称" prop="name" />
          <el-table-column label="访问路径" prop="path" />
          <el-table-column label="上传人员" align="center" prop="creator" width="120" />
          <el-table-column label="上传日期" align="center" prop="createTime" width="120">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" width="160">
            <template slot-scope="scope">
              <el-button size="mini" type="text" icon="el-icon-view" @click="viewGltfModel(scope.row)">浏览</el-button>
              <el-button size="mini" type="text" style="color:red;" icon="el-icon-delete" @click="handleDeleteObject(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-card>

        <el-card style="margin-top:10px" v-if="dataAuth==false">
            <div slot="header" class="clearfix">
                <span style="font-weight:bold;font-size:18px;color:#329dff;">数据集权限</span>
            </div>
            <el-tabs v-model="activeNameView" @tab-click="handleClickView">
                <el-tab-pane label="项目数据集权限" name="vfirst">
                    <el-table :data="projectList" border ref="tablep1">
                        <el-table-column type="selection" width="55" align="center" :selectable="selectablep" />
                        <el-table-column label="序号" align="center" type="index" width="55" />
                        <el-table-column label="名称" align="center" prop="name" />
                        <el-table-column label="编码" align="center" prop="code" />
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="工程数据集权限" name="vsecond">
                    <el-table :data="engineerList" border ref="tablee1">
                        <el-table-column type="selection" width="55" align="center" :selectable="selectablee" />
                        <el-table-column label="序号" align="center" type="index" width="55" />
                        <el-table-column label="名称" align="center" prop="name" />
                        <el-table-column label="编码" align="center" prop="code" />
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="子工程数据集权限" name="vthird">
                    <el-table :data="subEngineerList" border ref="tablese1">
                        <el-table-column type="selection" width="55" align="center" :selectable="selectablese" />
                        <el-table-column label="序号" align="center" type="index" width="55" />
                        <el-table-column label="名称" align="center" prop="name" />
                        <el-table-column label="编码" align="center" prop="code" />
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="站点数据集权限" name="vfourth">
                    <el-table :data="stationList" border ref="tables1">
                        <el-table-column type="selection" width="55" align="center" :selectable="selectables" />
                        <el-table-column label="序号" align="center" type="index" width="55" />
                        <el-table-column label="名称" align="center" prop="name" />
                        <el-table-column label="编码" align="center" prop="code" />
                    </el-table>
                </el-tab-pane>
            </el-tabs>
        </el-card>

        <el-card style="margin-top:10px" v-if="dataAuth==true">
            <div slot="header" class="clearfix">
                <span style="font-weight:bold;font-size:18px;color:#329dff;">数据集权限</span>
            </div>
            <el-tabs v-model="activeNameAuth" @tab-click="handleClickAuth">
                <el-tab-pane label="项目数据集权限" name="afirst">
                    <el-table :data="projectList" border @selection-change="handleSelectionChangeP" :row-key="getRowKeysP" ref="tablep">
                        <el-table-column type="selection" width="55" align="center" :selectable="selectablep" />
                        <el-table-column label="序号" align="center" type="index" width="55" />
                        <el-table-column label="名称" align="center" prop="name" />
                        <el-table-column label="编码" align="center" prop="code" />
                        <el-table-column label="操作" align="center" width="160">
                            <template slot-scope="scope">
                                <el-button v-if="scope.row.hasRole==1" type="text" @click="unhookDatasetProject(scope.row)">解除权限</el-button>
                            </template>
                        </el-table-column>
                    </el-table>

                    <center>
                        <el-button type="primary" style="margin-top:20px" @click="saveDatasetProjects">保存数据集项目</el-button>
                    </center>
                </el-tab-pane>
                <el-tab-pane label="工程数据集权限" name="asecond">
                    <el-table :data="engineerList" border @selection-change="handleSelectionChangeE" :row-key="getRowKeysE" ref="tablee">
                        <el-table-column type="selection" width="55" align="center" :selectable="selectablee" />
                        <el-table-column label="序号" align="center" type="index" width="55" />
                        <el-table-column label="名称" align="center" prop="name" />
                        <el-table-column label="编码" align="center" prop="code" />
                        <el-table-column label="操作" align="center" width="160">
                            <template slot-scope="scope">
                                <el-button v-if="scope.row.hasRole==1" type="text" @click="unhookDatasetEngineer(scope.row)">解除权限</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <center>
                        <el-button type="primary" style="margin-top:20px" @click="saveDatasetEngineer">保存数据集工程</el-button>
                    </center>
                </el-tab-pane>
                <el-tab-pane label="子工程数据集权限" name="athird">
                    <el-table :data="subEngineerList" border @selection-change="handleSelectionChangeSe" :row-key="getRowKeysSe" ref="tablese">
                        <el-table-column type="selection" width="55" align="center" :selectable="selectablese" />
                        <el-table-column label="序号" align="center" type="index" width="55" />
                        <el-table-column label="名称" align="center" prop="name" />
                        <el-table-column label="编码" align="center" prop="code" />
                        <el-table-column label="操作" align="center" width="160">
                            <template slot-scope="scope">
                                <el-button v-if="scope.row.hasRole==1" type="text" @click="unhookDatasetSubEngineer(scope.row)">解除权限</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <center>
                        <el-button type="primary" style="margin-top:20px" @click="saveDatasetSubEngineer">保存数据集子工程</el-button>
                    </center>
                </el-tab-pane>
                <el-tab-pane label="站点数据集权限" name="afourth">
                    <el-table :data="stationList" border @selection-change="handleSelectionChangeS" :row-key="getRowKeysS" ref="tables">
                        <el-table-column type="selection" width="55" align="center" :selectable="selectables" />
                        <el-table-column label="序号" align="center" type="index" width="55" />
                        <el-table-column label="名称" align="center" prop="name" />
                        <el-table-column label="编码" align="center" prop="code" />
                        <el-table-column label="操作" align="center" width="160">
                            <template slot-scope="scope">
                                <el-button v-if="scope.row.hasRole==1" type="text" @click="unhookDatasetStation(scope.row)">解除权限</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <center>
                        <el-button type="primary" style="margin-top:20px" @click="saveDatasetStation" >保存数据集站点</el-button>
                    </center>
                </el-tab-pane>
            </el-tabs>
        </el-card>

    </el-dialog>
  </div>
</template>

<script>
import { listOffShelfDataset } from "@/api/system/dataset";
import { getDatasetObjectsList,deleteObjectInfo } from "@/api/system/objectinfo";
import { getDatasetProjectList,saveDatasetProjects,unhookDatasetProject,getBindDatasetProjectList } from "@/api/system/project";
import { getDatasetEngineerList,saveDatasetEngineer,unhookDatasetEngineer,getBindDatasetEngineerList } from "@/api/system/engineer";
import { getDatasetSubEngineerList,saveDatasetSubEngineer,unhookDatasetSubEngineer,getBindDatasetSubEngineerList } from "@/api/system/subengineer";
import { getDatasetStationList,saveDatasetStation,unhookDatasetStation,getBindDatasetStationList } from "@/api/system/station";
export default {
  name: "DatasetAuth",
  dicts: ['sy_dataset_status','sy_dataset_type'],
  data() {
    return {
        projectList: [],
        engineerList: [],
        subEngineerList: [],
        stationList: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      idsp: [],
      // 非单个禁用
      singlep: true,
      // 非多个禁用
      multiplep: true,
      // 选中数组
      idse: [],
      // 非单个禁用
      singlee: true,
      // 非多个禁用
      multiplee: true,
      // 选中数组
      idsse: [],
      // 非单个禁用
      singlese: true,
      // 非多个禁用
      multiplese: true,
      // 选中数组
      idss: [],
      // 非单个禁用
      singles: true,
      // 非多个禁用
      multiples: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 数据集表格数据
      datasetList: [],
      datasetInfo: {},
      objectsList: [],
      activeNameAuth: "afirst",
      activeNameView: "vfirst",
      dataAuth: false,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      vTitle: "",
      vOpen: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        code: null,
        type: null,
        describe: null,
        status: null,
        path: null,
        projectIds: null,
        engineerIds: null,
        subEngineerIds: null,
        stationIds: null,
        roleIds: null,
        publishTime: null,
        publishId: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    handleClickView(tab, event){
        if(tab.index==1){
            let query = {
                uuid: this.datasetInfo.uuid
            }
            getBindDatasetEngineerList(query).then(res => {
                this.engineerList = [];
                this.engineerList = res.data;
                var that = this;
                that.$nextTick(() => {
                this.engineerList.forEach((v, i) => {
                    if (v.hasRole == 1) {
                        this.$refs.tablee1.toggleRowSelection(v, true);
                    }
                });
                });
            })
        }else if(tab.index==2){
            let query = {
                uuid: this.datasetInfo.uuid
            }
            getBindDatasetSubEngineerList(query).then(res => {
                this.subEngineerList = [];
                this.subEngineerList = res.data;
                var that = this;
                that.$nextTick(() => {
                this.subEngineerList.forEach((v, i) => {
                    if (v.hasRole == 1) {
                        this.$refs.tablese1.toggleRowSelection(v, true);
                    }
                });
                });
            })
        }else if(tab.index==3){
            let query = {
                uuid: this.datasetInfo.uuid
            }
            getBindDatasetStationList(query).then(res => {
                this.stationList = [];
                this.stationList = res.data;
                var that = this;
                that.$nextTick(() => {
                this.stationList.forEach((v, i) => {
                    if (v.hasRole == 1) {
                        this.$refs.tables1.toggleRowSelection(v, true);
                    }
                });
                });
            })
        }else if(tab.index==0){
            let query = {
                uuid: this.datasetInfo.uuid
            }
            getBindDatasetProjectList(query).then(res => {
                this.projectList = [];
                this.projectList = res.data;
                var that = this;
                that.$nextTick(() => {
                this.projectList.forEach((v, i) => {
                    if (v.hasRole == 1) {
                        this.$refs.tablep1.toggleRowSelection(v, true);
                    }
                });
                });
            })
        }
    },
    handleClickAuth(tab, event){
        if(tab.index==1){
            let query = {
                uuid: this.datasetInfo.uuid
            }
            getDatasetEngineerList(query).then(res => {
                this.engineerList = [];
                this.engineerList = res.data;
                var that = this;
                that.$nextTick(() => {
                this.engineerList.forEach((v, i) => {
                    if (v.hasRole == 1) {
                        this.$refs.tablee.toggleRowSelection(v, true);
                    }
                });
                });
            })
        }else if(tab.index==2){
            let query = {
                uuid: this.datasetInfo.uuid
            }
            getDatasetSubEngineerList(query).then(res => {
                this.subEngineerList = [];
                this.subEngineerList = res.data;
                var that = this;
                that.$nextTick(() => {
                this.subEngineerList.forEach((v, i) => {
                    if (v.hasRole == 1) {
                        this.$refs.tablese.toggleRowSelection(v, true);
                    }
                });
                });
            })
        }else if(tab.index==3){
            let query = {
                uuid: this.datasetInfo.uuid
            }
            getDatasetStationList(query).then(res => {
                this.stationList = [];
                this.stationList = res.data;
                var that = this;
                that.$nextTick(() => {
                this.stationList.forEach((v, i) => {
                    if (v.hasRole == 1) {
                        this.$refs.tables.toggleRowSelection(v, true);
                    }
                });
                });
            })
        }else if(tab.index==0){
            let query = {
                uuid: this.datasetInfo.uuid
            }
            getDatasetProjectList(query).then(res => {
                this.projectList = [];
                this.projectList = res.data;
                var that = this;
                that.$nextTick(() => {
                this.projectList.forEach((v, i) => {
                    if (v.hasRole == 1) {
                        this.$refs.tablep.toggleRowSelection(v, true);
                    }
                });
                });
            })
        }
    },
    handleDeleteObject(row){
      this.$modal.confirm('是否确认发布 "' + row.name + '" ？').then(function() {
        return deleteObjectInfo({uuid:row.uuid});
      }).then(() => {
        this.$modal.msgSuccess("删除成功");
        getDatasetObjectsList({datasetId:this.datasetInfo.uuid}).then(res =>{
          this.objectsList = [];
          this.objectsList = res.data;
        })
      }).catch(() => {});
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    getList() {
      this.loading = true;
      listOffShelfDataset(this.queryParams).then(response => {
        this.datasetList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    handleView(row){
      this.vTitle = "数据集权限详情";
      this.vOpen = true;
      this.datasetInfo = row;
      this.objectsList = [];
      this.activeNameView = "vfirst";
      this.dataAuth = false;
      getDatasetObjectsList({datasetId:row.uuid}).then(res =>{
        this.objectsList = res.data;
      })
      let query = {
            uuid: this.datasetInfo.uuid
        }
        getBindDatasetProjectList(query).then(res => {
            this.projectList = [];
            this.projectList = res.data;
            var that = this;
            that.$nextTick(() => {
            this.projectList.forEach((v, i) => {
                if (v.hasRole == 1) {
                    this.$refs.tablep1.toggleRowSelection(v, true);
                }
            });
            });
        })
    },
    handleDataAuth(row){
      this.vTitle = "数据集权限分配";
      this.vOpen = true;
      this.datasetInfo = row;
      this.objectsList = [];
      this.dataAuth = true;
      this.activeNameAuth = "afirst";
      getDatasetObjectsList({datasetId:row.uuid}).then(res =>{
        this.objectsList = res.data;
      })

      // 获取数据集项目信息
      let query = {
        uuid: row.uuid
      }
      getDatasetProjectList(query).then(res =>{
        this.projectList = [];
        this.projectList = res.data;
        var that = this;
        that.$nextTick(() => {
        this.projectList.forEach((v, i) => {
            if (v.hasRole == 1) {
                this.$refs.tablep.toggleRowSelection(v, true);
            }
        });
        });
      })
    },
    saveDatasetProjects(){
        if(this.idsp.length>0){
            let data = {
                ids: this.idsp.join(","),
                uuid: this.datasetInfo.uuid
            }
            saveDatasetProjects(data).then(res =>{
                this.$modal.msgSuccess("保存成功");
                let query = {
                    uuid: this.datasetInfo.uuid
                }
                getDatasetProjectList(query).then(res =>{
                    this.projectList = [];
                    this.projectList = res.data;
                    var that = this;
                    that.$nextTick(() => {
                    this.projectList.forEach((v, i) => {
                        if (v.hasRole == 1) {
                            this.$refs.tablep.toggleRowSelection(v, true);
                        }
                    });
                    });
                })
            })
        }else{
            this.$message.error('请勾选项目！')
        }
    },
    saveDatasetEngineer(){
       if(this.idse.length>0){
            let data = {
                ids: this.idse.join(","),
                uuid: this.datasetInfo.uuid
            }
            saveDatasetEngineer(data).then(res =>{
                this.$modal.msgSuccess("保存成功");
                let query = {
                    uuid: this.datasetInfo.uuid
                }
                getDatasetEngineerList(query).then(res => {
                    this.engineerList = [];
                    this.engineerList = res.data;
                    var that = this;
                    that.$nextTick(() => {
                    this.engineerList.forEach((v, i) => {
                        if (v.hasRole == 1) {
                            this.$refs.tablee.toggleRowSelection(v, true);
                        }
                    });
                    });
                })
            });
       }else{
            this.$message.error('请勾选工程！')
        }
    },
    saveDatasetSubEngineer(){
        if(this.idsse.length>0){
            let data = {
                ids: this.idsse.join(","),
                uuid: this.datasetInfo.uuid
            }
            saveDatasetSubEngineer(data).then(res =>{
                this.$modal.msgSuccess("保存成功");
                let query = {
                    uuid: this.datasetInfo.uuid
                }
                getDatasetSubEngineerList(query).then(res => {
                    this.subEngineerList = [];
                    this.subEngineerList = res.data;
                    var that = this;
                    that.$nextTick(() => {
                    this.subEngineerList.forEach((v, i) => {
                        if (v.hasRole == 1) {
                            this.$refs.tablese.toggleRowSelection(v, true);
                        }
                    });
                    });
                })
            })
        }else{
            this.$message.error('请勾选子工程！')
        }
    },
    saveDatasetStation(){
        if(this.idss.length>0){
            let data = {
                ids: this.idss.join(","),
                uuid: this.datasetInfo.uuid
            }
            saveDatasetStation(data).then(res =>{
                this.$modal.msgSuccess("保存成功");
                let query = {
                    uuid: this.datasetInfo.uuid
                }
                getDatasetStationList(query).then(res => {
                    this.stationList = [];
                    this.stationList = res.data;
                    var that = this;
                    that.$nextTick(() => {
                    this.stationList.forEach((v, i) => {
                        if (v.hasRole == 1) {
                            this.$refs.tables.toggleRowSelection(v, true);
                        }
                    });
                    });
                })
            })
        }else{
            this.$message.error('请勾选站点！')
        }
    },
    unhookDatasetProject(row){
        let data = {
            ids: row.uuid,
            uuid: this.datasetInfo.uuid
        }
        unhookDatasetProject(data).then(res =>{
            let query = {
                uuid: this.datasetInfo.uuid
            }
            getDatasetProjectList(query).then(res =>{
                this.projectList = [];
                this.projectList = res.data;
                var that = this;
                that.$nextTick(() => {
                this.projectList.forEach((v, i) => {
                    if (v.hasRole == 1) {
                        this.$refs.tablep.toggleRowSelection(v, true);
                    }
                });
                });
            })
        })
    },
    unhookDatasetEngineer(row){
        let data = {
            ids: row.uuid,
            uuid: this.datasetInfo.uuid
        }
        unhookDatasetEngineer(data).then(res =>{
            let query = {
                uuid: this.datasetInfo.uuid
            }
            getDatasetEngineerList(query).then(res => {
                this.engineerList = [];
                this.engineerList = res.data;
                var that = this;
                that.$nextTick(() => {
                this.engineerList.forEach((v, i) => {
                    if (v.hasRole == 1) {
                        this.$refs.tablee.toggleRowSelection(v, true);
                    }
                });
                });
            })
        })
    },
    unhookDatasetSubEngineer(row){
        let data = {
            ids: row.uuid,
            uuid: this.datasetInfo.uuid
        }
        unhookDatasetSubEngineer(data).then(res =>{
            let query = {
                uuid: this.datasetInfo.uuid
            }
            getDatasetSubEngineerList(query).then(res => {
                this.subEngineerList = [];
                this.subEngineerList = res.data;
                var that = this;
                that.$nextTick(() => {
                this.subEngineerList.forEach((v, i) => {
                    if (v.hasRole == 1) {
                        this.$refs.tablese.toggleRowSelection(v, true);
                    }
                });
                });
            })
        });
    },
    unhookDatasetStation(row){
        let data = {
            ids: row.uuid,
            uuid: this.datasetInfo.uuid
        }
        unhookDatasetStation(data).then(res =>{
            let query = {
                uuid: this.datasetInfo.uuid
            }
            getDatasetStationList(query).then(res => {
                this.stationList = [];
                this.stationList = res.data;
                var that = this;
                that.$nextTick(() => {
                this.stationList.forEach((v, i) => {
                    if (v.hasRole == 1) {
                        this.$refs.tables.toggleRowSelection(v, true);
                    }
                });
                });
            })
        }); 
    },
    // 多选框选中数据
    handleSelectionChangeP(selection) {
      this.idsp = selection.map(item => item.uuid)
      this.singlep = selection.length!=1
      this.multiplep = !selection.length
    },
    selectablep(row, index) {
      if (row.hasRole == 1) {
        return false; // 禁用
      } else {
        return true; //不禁用
      }
    },
    getRowKeysP(row) {
      return row.uuid;
    },
    // 多选框选中数据
    handleSelectionChangeE(selection) {
      this.idse = selection.map(item => item.uuid)
      this.singlee = selection.length!=1
      this.multiplee = !selection.length
    },
    selectablee(row, index) {
      if (row.hasRole == 1) {
        return false; // 禁用
      } else {
        return true; //不禁用
      }
    },
    getRowKeysE(row) {
      return row.uuid;
    },
    // 多选框选中数据
    handleSelectionChangeSe(selection) {
      this.idsse = selection.map(item => item.uuid)
      this.singlese = selection.length!=1
      this.multiplese = !selection.length
    },
    selectablese(row, index) {
      if (row.hasRole == 1) {
        return false; // 禁用
      } else {
        return true; //不禁用
      }
    },
    getRowKeysSe(row) {
      return row.uuid;
    },
    // 多选框选中数据
    handleSelectionChangeS(selection) {
      this.idss = selection.map(item => item.uuid)
      this.singles = selection.length!=1
      this.multiples = !selection.length
    },
    selectables(row, index) {
      if (row.hasRole == 1) {
        return false; // 禁用
      } else {
        return true; //不禁用
      }
    },
    getRowKeysS(row) {
      return row.uuid;
    },
  }
};
</script>
